<?php

?>
<html>
    <?php include('include.header.html'); ?>
    <body class="bodycliente">
       

        <div id="usuario" align="center">
            
            
            <table class="marco">
            <tr>
                <td height="10%">
                <?php include('menu_clientes.php'); ?>
                </td>
                </tr>
                <tr>
                    <td align="center">
                     <form id="frm_bp" name="frm_bp" method="post">
				<input type="hidden" name="activar" value="1" id="activar">	
                         <br><br>
                         <div id="DATO_HIDE" style="display:none" style="width:90%">
                        <div id="DATO" class="mensajes"></div>
                        </div>
                         <br><br>
                    <table class="formulario" width="60%">
            
                        <tr>
                <td>
                 Mail  
                </td>
                <td>
                    <input type="text" id="usuario" name="usuario" class="validate['required']">
                </td>
            </tr>
             <tr>
                <td>
                  clave  
                </td>
                <td>
                    <input type="password" id="clave" name="clave" class="validate['required']">
                </td>
            </tr>
            <tr>
                <td colspan='2'>
                <a href='olvido_clave.php'>olvid&oacute; su clave?</a>
                 </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <input type="submit" name="submit" id="submit" value="Ingresar">
                </td>
            </tr>
                    </table>
                    <br>
                    </td>
                </tr>
	    <tr>
		<td>
                    <br> 
                </td>
            </tr>
            <tr>
                    <td>
                       <br><br><br><br>
                    </td>
            </tr>
            <tr>
			<td height="10%" valign="bottom" align="center">
			<?php include('footer.php'); ?>
			</td>
			</tr>
            </table>
            
        </div>
        </form>
    </body>
    <?php include('include.footer.html'); ?>
    <script>
    ///////////////////////////////
    var myCheck;
	myCheck = new FormCheck('frm_bp', {
	  submit:false,
		display:{
			errorsLocation : 1,
			indicateErrors : 2,
			keepFocusOnError : 0,
			closeTipsButton : 1,
			checkValueIfEmpty:1,                
			showErrors : 1
		}
	});		 
 
    $('frm_bp').addEvent('submit',function(ev){
        var IsValid;
       IsValid=myCheck.isFormValid();                                                                          
        if (IsValid){ 
           Ejecutor();
        }    
    });
    ///////////////////////////////

    function Ejecutor(){        
        window.addEvent('domready', function() {      	       
    		var req = new Request.JSON({
                method: 'POST',
                url: 'ajax/ajax_autenticar_clientes.php', 
                data: $('frm_bp'),                
                noCache:true,                     
                onRequest: function(){
                    $('submit').disabled = true;
                    $('DATO_HIDE').show();
//                    $('DATO').innerHTML = 'Procesando ...'; 
                },
                onComplete: function(){
                    setTimeout(function(){
                        $('DATO_HIDE').fade('out').get('tween').chain(function() {
                            $('DATO_HIDE').hide();
                            $('DATO_HIDE').fade('in');                                                         
                        });
                    },2000);                                                                                                                                                                                                              
                },             
                onSuccess: function(response){
                    switch(parseInt(response.RESULT)){
                        case 0:
                            $('DATO').innerHTML = "Operaci&oacute;n exitosa";  
                            window.location='inicio.php';
                            break;
                        case 1:
                            $('DATO').innerHTML = response.ERROR;
                            $('submit').disabled = false;
                            break;
                    }
                }
            }).post();        
       });
    }
    </script>
</html>
